package com.fullhome8.cn.wanghongweb.controller.restful;

import com.fullhome8.cn.wanghongweb.model.News;
import com.fullhome8.cn.wanghongweb.service.NewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author: yuanxuefeng
 * @version: 2017/8/18
 */
@Api(value = "news", description = "新闻资讯")
@RestController
@Slf4j
public class NewsResultController {

    @Autowired
    private NewService newService;


    @RequestMapping(value = "/rest/newsList", method = RequestMethod.GET)
    @ApiOperation(value = "查询新闻列表", notes = "Get city by state", response = News.class)
    public List<News> queryNews() {
        return newService.queryNewsList();
    }

    @RequestMapping(value = "/rest/insert", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "news", value = "新闻资讯实体", required = true, dataType = "News"),
            @ApiImplicitParam(name = "news", value = "新闻资讯实体", required = true, dataType = "News")
    })
    @ApiOperation(value = "新增新闻", notes = "Get city by state", response = News.class)
    public String insertNews(@RequestBody News news) {
        return "ok";
    }

}
